/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.schnipsel.zentral;

import de.mnit.basis.fehler.system.F_Sys_Datei;
import de.mnit.basis.sys.Sys;
import de.mnit.basis.sys.datei.DSLokal;
import de.mnit.basis.sys.datei.S_Datei;
import de.mnit.basis.sys.datei.S_Ordner;
import de.mnit.schnipsel.Anw_Schnipsel;

/**
 * @author Michael Nitsche
 * 06.07.2010	Erstellt
 */
public class SC_DateiSys {

	private static S_Ordner ordner=null;
	private static final String dbname="db";


	private static S_Ordner gOrdnerKonfig() throws F_Sys_Datei {
		if(SC_Portable.gib())
			return DSLokal.aktuell();
		return ordner!=null
			? ordner
			: (ordner=DSLokal.gOrdnerAnwNitsche("schnipsel"));
	}

	public static S_Ordner gOrdnerDB() throws F_Sys_Datei {
		return gOrdnerKonfig().oF(dbname+iDebug());
	}

	public static S_Datei gStandardDB() throws F_Sys_Datei {
		return gOrdnerDB().dF(dbname);
	}

	public static S_Ordner gOrdnerLog() throws F_Sys_Datei {
		return gOrdnerKonfig().oF("log");
	}

	public static S_Datei gDateiKonfig() throws F_Sys_Datei {
		return gOrdnerKonfig().dF("schnipsel"+iDebug(), "properties");
	}

	public static S_Datei gDateiKonfigDB() throws F_Sys_Datei {
		return gOrdnerDB().dF("dbs", "properties");
	}

	public static String gPortableDB() {
		return dbname+iDebug()+Sys.gTrennerVerz()+dbname;
	}

	// INTERN

	private static String iDebug() {
		return Anw_Schnipsel.DEBUG_DATEN
			? "_debug"
			: "";
	}
}
